﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using MP.LayerHelper.MP_OBS.BLL;
using MP.LayerHelper.MP_OBS.DAL.EntityClasses;
using MP.LayerHelper.MP_OBS.DAL.HelperClasses;

using MP.Core.Library;
using MP.Core.Config;
public partial class Admin_Hurman_Controls_ListDepart : MP.Core.Authentication.Control.AuthenBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        InitAuthen(EnumModules.DEPART);
        if (!IsPostBack)
        {
            loadData();
        }
    }

    void loadData()
    {
        DataSet dst = MaDepartmentManager.CreateInstant().GetAllDepart();
        repDepart.DataSource = dst;
        repDepart.DataBind();
    }

    protected void repDepart_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        switch (e.CommandName)
        {
            case "del":
                MaDepartmentEntity depart = MaDepartmentManager.CreateInstant().GetById(new Guid(e.CommandArgument.ToString()));
                if (depart != null)
                {
                    depart.IsDeleted = true;
                    depart.UpdatedDate = DateTime.Now;
                    depart.UpdatedBy = Util.CurrentUserName;
                    MaDepartmentManager.CreateInstant().Update(depart);
                    Response.Redirect(Request.RawUrl);
                }
                break;
        }
    }
}
